<?php
/**
 * Created by PhpStorm.
 * User: lyh
 * Date: 2017/4/23
 * Time: 21:09
 */
namespace Admin\Controller;
use Think\Controller;

class TestController extends Controller{
    public function demo(){
        $post_id=M('Areacomment')->where('id= 3')->getField('pid');
        M('Areapost')->where('id='.$post_id)->setDec('commentcount',1);
        dump($post_id);
    }

    public function upload(){
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     3145728 ;// 设置附件上传大小
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath  =      './Public/Uploads/'; // 设置附件上传根目录
        // 上传单个文件
        $info   =   $upload->uploadOne($_FILES['img']);
        if(!$info) {// 上传错误提示错误信息
            return 'error';
        }else{// 上传成功 获取上传文件信息
            return '/Public/Uploads/'.$info['savepath'].$info['savename'];
        }
    }

}